import React from 'react';
import {useRequest} from 'umi';
import {Card, notification} from 'antd';
// import {PageContainer} from '@ant-design/pro-layout';
import PageHeader from '@/components/PageHeader';
import Renderer from '@gaotu-fe/imis-render';
// import config from './json/crud';
import {getImisConfig} from '@/services/imis';

const IMisPage = props => {
    const {route: {imisId, name}} = props;

    const {data: jsonData} = useRequest(getImisConfig, {
        defaultParams: [{alias: imisId}],
        onError(error) {
            notification.error({message: error.message});
        }
    });

    const pageConfig = jsonData?.[0]?.detail ? JSON.parse(jsonData?.[0]?.detail) : null;

    return (
        <PageHeader>
            <Card
                bodyStyle={{padding: 0, margin: 0, paddingTop: 10}}
                bordered={false}
            >
                <Renderer config={pageConfig} />
            </Card>
        </PageHeader>
    );
};

export default IMisPage;
